class QMResponse {
  bool success = false;
  String errorMessage = '';
  dynamic data;

  QMResponse(this.success, [this.errorMessage = '', this.data]);

  bool isSuccess() {
    return success == true;
  }

  QMResponse.fromMap(Map<dynamic, dynamic>? map) {
    if (map?['success'] is bool) {
      success = map?['success'];
    } else if (map?['success'] is int) {
      success = map?['success'] == 1;
    }

    if (map?['message'] is String) {
      errorMessage = map?['message'];
    }
    data = map?['data'];
  }
}
